#include <algorithm>
#include <BSP/Sensor.h>
#include <atomic>

static std::atomic g_temperature_c{20};

extern "C" {
void sensor_init()
{
    g_temperature_c.store(20, std::memory_order_relaxed);
}

void sensor_set_temperature_c(int value)
{
    value = std::clamp(value, -5, 35);
    g_temperature_c.store(value, std::memory_order_relaxed);
}

int sensor_get_temperature_c()
{
    return g_temperature_c.load(std::memory_order_relaxed);
}
}

